﻿using System;
using Flagwind.Options;
using Flagwind.Options.Configuration;
namespace Flagwind.Data.Configuration
{
	public class MappingElement : OptionConfigurationElement
	{
		#region 常量定义
		private const string XML_NAME_ATTRIBUTE = "name";
		private const string XML_PATH_ATTRIBUTE = "path";
		#endregion
		#region 公共属性
		[OptionConfigurationProperty(XML_NAME_ATTRIBUTE, Behavior = OptionConfigurationPropertyBehavior.IsKey)]
		public string Name
		{
			get
			{
				return (string)this[XML_NAME_ATTRIBUTE];
			}
			set
			{
				if(string.IsNullOrWhiteSpace(value))
					throw new ArgumentNullException();
				this[XML_NAME_ATTRIBUTE] = value;
			}
		}
		[OptionConfigurationProperty(XML_PATH_ATTRIBUTE, Behavior = OptionConfigurationPropertyBehavior.IsRequired)]
		public string Path
		{
			get
			{
				return (string)this[XML_PATH_ATTRIBUTE];
			}
			set
			{
				if(string.IsNullOrWhiteSpace(value))
					throw new ArgumentNullException();
				this[XML_PATH_ATTRIBUTE] = value;
			}
		}
		#endregion
	}
}